-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added raise
statement
#135
Conversation
Syntax: raise ErrorType "Error Message"
Things like: raise RTError 1+1 or msg = "Error Message" raise TypeError msg would work now
The errortype should not be like a keyword rather should have to be like a function or class. Example:
Follow #83 for details. Also make sure, all tests are passing. Thanks for your contribution. Keep it up. 👍🏻 |
I don't think it will be possible to do it as a class because errors are not currently first-class citizens (
(To be clear, the reason I'm mentioning that is because it wouldn't be possible to do that with classes either. At least not as conveniently) |
I did think doing it with classes, but I thought it will be hard because classes don't support inheritance (like |
Maybe it could be function syntax but not actually a function call? Like:
That would be valid, but not actually calling any |
That seems like a good idea, but it will still allow any identifier to be an error type |
Which is, in my opinion, a Good Thing |
I think so too |
But I still think the idea with a function returning an error message is a better idea
|
Oooh! Never thought about doing it like that! Thought you would need inheritance to make it work but I guess not. Good idea! |
Syntax: raise FooError("message")
Now it is only possible to raise errors with function calls ``` fun ArgError(arg) { return "Argument `"+arg+"` not found" } raise ArgError("arg1") ``` The name of the function will also be the error type ``` ArgError: Argument `arg1` not found ```
Updated `raise.rn.json` to match the new output Removed debug line (parser.py:167)
Now the syntax I mentioned above should work as expected, I also added a simple test to the tests |
This reverts commit 6a6763d.
@Vardan2009 You need to test your local code before pushing to Github. Use |
Sorry, I was having some problems running the tests on my local machine, but I got it working now. I will try fixing these errors. |
Most important is to fix the |
Thanks, @Vardan2009 Stay contributing everyone. |
This was my first ever contribution to a project, thank you so much! |
Your welcome. |
@Vardan2009 You can join us here https://discord.gg/zJhwFzqxs7 |
The syntax:
raise errortype expression
Example:
raise TypeError "Input must be integer"